import redis

from game.models import UserRecord

class redisfile(object):

    def __init__(self):
        self.plat_id = UserRecord.objects.all().order_by('-add_time').values_list('platrecord_id').first()[0]
        self.conn = redis.Redis(host='127.0.0.1',port=6379,password='')
    def redises(self):
        bigs = []
        smalls = []
        for key in self.conn.scan_iter("beton_%s_*"%(self.plat_id)):
            title = self.conn.hget(key,'beton_key')
            img = self.conn.hget(key, 'small_big')
            # print(str(title,encoding='utf-8'))
            if str(img,encoding='utf-8') =="small":
                smalls.append(int(str(title, encoding='utf-8')))
            else:
                bigs.append(int(str(title, encoding='utf-8')))

        return (bigs,smalls)

redisfile().redises()





